#!/bin/sh

display_warning ()
{
	echo "Kernel version mismatch. Cable drivers will not be installed."
	if [ $TP_VERSION_2_4 = "1" ]
	then
		echo "Please see Answer Record 18612 to install the drivers." 
	else
		echo "Please see Answer Record 22648 to install the drivers." 
	fi;
}

TP_KERNEL_VERSION=`uname -r`
echo "--Kernel version = "$TP_KERNEL_VERSION.
echo "--Arch = `arch`".
TP_ARCH_64=`arch | grep -c "64"`
TP_VERSION_2_4=`uname -r | grep -c "2.4"`
if [ $TP_VERSION_2_4 = "0" ]
then
	display_warning
	exit 1
fi;
if [ $TP_ARCH_64 = "1" ]
then
	display_warning
	exit 1
fi;
if [ $TP_KERNEL_VERSION != "2.4.21-4.EL" ]
then
	if [ $TP_KERNEL_VERSION != "2.4.21-4.ELsmp" ]
	then
		if [ $TP_KERNEL_VERSION != "2.4.7-10" ]
		then
			if [ $TP_KERNEL_VERSION != "2.4.7-10smp" ]
			then
				if [ $TP_KERNEL_VERSION != "2.4.18-14" ]
				then
					if [ $TP_KERNEL_VERSION != "2.4.20-18.8smp" ]
					then
						display_warning
						exit 1
					fi;
				fi;
			fi;
		fi;
	fi;
fi;

module_dir="/lib/modules/misc"
cpu_count=`grep -c processor /proc/cpuinfo`
gcc_kernel_version=`cat /proc/version | sed -e "s/.*gcc version \([0-9]\).*/\1/"`
el_version=`uname -r`
if [ $cpu_count = "1" ]
then
	if [ $gcc_kernel_version = "2" ]
	then
		xpc4_file="xpc4u2.o"
		wdrv_file="windu2.o"
	else
		if [ $el_version = "2.4.21-4.EL" ]
		then
			xpc4_file="xpc4u3el.o"
			wdrv_file="windu3el.o"
		else
			xpc4_file="xpc4u3.o"
			wdrv_file="windu3.o"
		fi
	fi
else
	if [ $gcc_kernel_version = "2" ]
	then
		xpc4_file="xpc4s2.o"
		wdrv_file="winds2.o"
	else
		if [ $el_version = "2.4.21-4.ELsmp" ]
		then
			xpc4_file="xpc4s3el.o"
			wdrv_file="winds3el.o"
		else
			xpc4_file="xpc4s3.o"
			wdrv_file="winds3.o"
		fi
	fi
fi
#echo xpc4file is $xpc4_file
#echo wdrvfile is $wdrv_file
mkdir -p $module_dir
exec_dir=`pwd`
#echo execdir is $exec_dir
/bin/cp -uf $xpc4_file $module_dir/xpc4drvr.o 
/bin/cp -uf $wdrv_file $module_dir/windrvr6.o 
ln -sf $exec_dir/wdreg $module_dir/install_windrvr6
ln -sf $exec_dir/install_drv $module_dir/install_xpc4drvr
# End of file.
